//
//  CoreWork.m
//  FMJY
//
//  Created by 艾玩科技 on 17/4/5.
//  Copyright © 2017年 随心. All rights reserved.
//

#import "CoreWork.h"

#define KTestuser_snNOStr @"e563f6088a3c43fba7026b7e7c6754d6"

@implementation CoreWork

#pragma mark -- 用户登录app --
+(void)loginWithuname:(NSString *)uname upwd:(NSString *)upwd deviceToken:(NSString *)deviceToken deviceInfo:(NSString *)deviceInfo Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/app/app-login.htm",mainString];
   //deviceToken： 友盟的
    //用户名，密码
    NSDictionary *params = @{@"uname":uname,@"upwd":upwd,@"deviceToken":deviceToken,@"deviceInfo":deviceInfo};
    
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}

#pragma mark -- 用户退出app --
+(void)logOutWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    
    
    NSString *url = [NSString stringWithFormat:@"%@/app/app-logout.htm",mainString];
    
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
    
}

#pragma mark -- 签入车辆 --
+(void)signInWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *user_snNOStr = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"user_snNO"]];
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"user_snNO"]==nil) {
        user_snNOStr = KTestuser_snNOStr;
    }
    
    NSString *url = [NSString stringWithFormat:@"%@/sign/in/%@/",mainString,user_snNOStr];
    
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
       
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
    
}
#pragma mark -- 签出车辆 -- 
+(void)signOutWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
   
    
    NSString *url = [NSString stringWithFormat:@"%@/sign/out",mainString];
    
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
    
}
#pragma mark -- 开始 OR 停止 接单 --
+(void)startGetOrderWithloginToken:(NSString *)loginToken allowOrder:(NSString *)allowOrder Block:(void(^)(id responsObject))block
{
    //1 是可接单  0是不可接单
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/order-allow.htm",mainString];
    
    NSDictionary *params = @{@"loginToken":loginToken,@"allowOrder":allowOrder};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 司机到达事故现场 -- 
+(void)driverArrivedWithorderNo:(NSString *)orderNo loginToken:(NSString *)loginToken lng:(NSString *)lng lat:(NSString *)lat arrivePics:(NSString *)arrivePics Block:(void(^)(id responsObject))block

{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/arrive-order.htm",mainString];
    
    
    NSDictionary *params = @{@"orderNo":orderNo,@"loginToken":loginToken,@"lng":lng,@"lat":lat,@"arrivePics":arrivePics};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}

#pragma mark -- 司机到达事故现场 (图片是数组)--
+(void)driverArrivedWithorderNo:(NSString *)orderNo loginToken:(NSString *)loginToken lng:(NSString *)lng lat:(NSString *)lat arrivePicsArr:(NSMutableArray *)arrivePicsArr Block:(void(^)(id responsObject))block

{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/arrive-order.htm",mainString];
    
    
    NSDictionary *params = @{@"orderNo":orderNo,@"loginToken":loginToken,@"lng":lng,@"lat":lat,@"arrivePicsArr":arrivePicsArr};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark  --  司机未结单接口 --
+(void)UnFinishedOrderWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/not-accept-list.htm",mainString];
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
 
}

#pragma mark -- 获取司机已结订单列表
+(void)orderListWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/order-list.htm",mainString];
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork afGetHttpWihtRUL:url wihtParmas:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
    
}
#pragma mark -- 接单接口 -- 
+(void)getOrderWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/accept-order.htm",mainString];
    
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 取消回执 --
+(void)cancleBackWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/cancel-confirm-order.htm",mainString];
    
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma  mark -- 司机订单详情接口 -- 
+(void)getDetailOrderWithorderNo:(NSString *)orderNo loginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/order-detail.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 司机拖车上板 --
+(void)DriverArriveWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken trailPics:(NSString *)trailPics Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/trail-upper-order.htm",mainString];
      NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken,@"trailPics":trailPics};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}

#pragma mark -- 司机拖车上板 (图片是数组)--
+(void)DriverArriveWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken trailPicsArr:(NSMutableArray *)trailPicsArr Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/trail-upper-order.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken,@"trailPicsArr":trailPicsArr};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma  mark -- 订单完成的接口 --
+(void)OrderCompleteWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken destPics:(NSString *)destPics Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/order-complete.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken,@"destPics":destPics};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];

}

#pragma  mark -- 订单完成的接口 --（图片是数组）
+(void)OrderCompleteWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken destPicsArr:(NSMutableArray *)destPicsArr Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/order-complete.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken,@"destPicsArr":destPicsArr};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
    
}
#pragma mark -- 司机接单时选择到达现场的时间  --
+(void)DriverBeSureArriveTimeWithorderNo:(NSString *)orderNo arriveTime:(NSString *)arriveTime loginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
  
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/update-come-time.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"arriveTime":arriveTime,@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 服务商订单列表 -- 
+(void)ServiceProviderUnFinishOrderListWithloginToken:(NSString *)loginToken page:(NSNumber* )page pageSize:(NSNumber* )pageSize Block:(void(^)(id responsObject))block
{
//    public Integer page = 1;
//    public Integer pageSize = 10
    NSString *url = [NSString stringWithFormat:@"%@/driver/dealer/order-list.htm",mainString];
    NSDictionary *params = @{@"loginToken":loginToken,@"page":page,@"pageSize":pageSize};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 服务商 拒绝接单  OR 接单 接口 -- 
+(void)ServiceRejectGetOrderWithorderNo:(NSString *)orderNo lng:(NSString *)lng lat:(NSString *)lat loginToken:(NSString *)loginToken flag:(NSString *)flag Block:(void(^)(id responsObject))block
{
    //flag = 0拒单，flag=1接单
    NSString *url = [NSString stringWithFormat:@"%@/driver/dealer/order-receive.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"lng":lng,@"lat":lat,@"loginToken":loginToken,@"flag":flag};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}
#pragma mark -- 分配司机 --
+(void)assignDriverWithorderNo:(NSString *)orderNo  loginToken:(NSString *)loginToken userDriverId:(NSString *)userDriverId Block:(void(^)(id responsObject))block

{
    //userDriverId司机ID
    NSString *url = [NSString stringWithFormat:@"%@/driver/dealer/assign-driver.htm",mainString];
    NSDictionary *params = @{@"orderNo":orderNo,@"loginToken":loginToken,@"userDriverId":userDriverId};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];

}
#pragma mark -- 更改司机 --
+(void)changeDriverWithorderNo:(NSString *)orderNo orderMark:(NSString *)orderMark  loginToken:(NSString *)loginToken userDriverId:(NSString *)userDriverId Block:(void(^)(id responsObject))block
{
//    orderMark 备注
    NSString *url = [NSString stringWithFormat:@"%@/driver/dealer/change-driver.htm",mainString];
    
    NSDictionary *params = @{@"orderNo":orderNo,@"orderMark":orderMark,@"loginToken":loginToken,@"userDriverId":userDriverId};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];
}

#pragma mark  --  查询在线司机 --
+(void)onlineDriverWithloginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url =[NSString stringWithFormat:@"%@/driver/dealer/get-online-drivers.htm",mainString];
    NSDictionary *params = @{@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];

}
#pragma mark -- 司机完成订单时添加备注 --
+(void)addBeizhuWithorderNo:(NSString *)orderNo orderMark:(NSString *)orderMark  loginToken:(NSString *)loginToken Block:(void(^)(id responsObject))block
{
    NSString *url = [NSString stringWithFormat:@"%@/driver/order/add-order-mark.htm",mainString];
     NSDictionary *params = @{@"orderNo":orderNo,@"orderMark":orderMark,@"loginToken":loginToken};
    [RequestWork POSTOfAFNWithURL:url pamars:params successBackBlock:^(id responsobject) {
        block(responsobject);
    } fileBackBlock:^(id reponsobject) {
        block(reponsobject);
    }];

}
@end
